import { DeviceEventEmitter, NativeModules } from "react-native";
const { UtilsLibrary } = NativeModules;

export default class Utils{
    static eventHandler = null;
    static installNetMonitor(listener) {
        if(this.eventHandler != null) {
            this.eventHandler.remove();
        } 
        this.eventHandler = DeviceEventEmitter.addListener("net_events", (data)=>{
            if(listener != null) {
                listener(data);
            }
        });
    }

    static uninstallNetMonitor() {
        if(this.eventHandler != null) {
            this.eventHandler.remove();
        }
    }

    static gotoActivity(activityName) {
        return UtilsLibrary.gotoActivity(activityName);
    }

    static async getMachineIp() {
        return UtilsLibrary.getMachineIp();
    }
}